package client;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.Action;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JToolBar;
import javax.swing.text.StyledEditorKit;
import javax.swing.text.html.HTMLEditorKit;

public class StyledEditorTest extends JFrame{

	public StyledEditorTest() {
		JEditorPane editorPane = new JEditorPane();
		editorPane.setContentType("text/HTML");
		editorPane.setEditorKit(new HTMLEditorKit());
		editorPane.setText("<hr>Welcome to <b>StackOverFlow!</b><hr>");
		
		JToolBar bar = new JToolBar();
//		bar.add(new StyledEditorKit.ForegroundAction("Red", Color.red));
//		bar.add(new StyledEditorKit.ForegroundAction("Blue", Color.blue));
//		bar.add(new JSeparator());
//		bar.add(new StyledEditorKit.FontSizeAction("12", 12));
//		bar.add(new StyledEditorKit.FontSizeAction("14", 14));
//		bar.add(new StyledEditorKit.FontSizeAction("16", 16));
//		bar.add(new JSeparator());
//		bar.add(new StyledEditorKit.BoldAction());
//		bar.add(new StyledEditorKit.ItalicAction());
//		bar.add(new StyledEditorKit.UnderlineAction());
//		bar.add(new JSeparator());
//		
//		bar.add(new StyledEditorKit.AlignmentAction("left", StyleConstants.ALIGN_LEFT));
//		bar.add(new StyledEditorKit.AlignmentAction("center", StyleConstants.ALIGN_CENTER));
//		bar.add(new StyledEditorKit.AlignmentAction("rigth", StyleConstants.ALIGN_RIGHT));
//		
//		bar.add(new StyledEditorKit.AlignmentAction("justified", StyleConstants.ALIGN_JUSTIFIED));
		
		StyledEditorKit styledEditorKit = new StyledEditorKit();
		
		Action[] actions = styledEditorKit.getActions();
		
		for (Action action : actions) {
			bar.add(action);
    }
		
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setLocationRelativeTo(null);
		this.add(bar, BorderLayout.NORTH);
		this.add(editorPane, BorderLayout.CENTER);
		this.pack();
		this.setVisible(true);
	}

	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {

			@Override
			public void run() {
				new StyledEditorTest();
			}
		});
	}

}
